package com.yixia.pea.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yixia.pea.domain.credit.PeaHzFam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;

/**
* @author 35038
* @description 针对表【pea_hz_fam】的数据库操作Mapper
* @createDate 2023-09-01 08:33:15
* @Entity com.yixia.pea.domain.credit.PeaHzFam
*/
public interface PeaHzFamMapper extends BaseMapper<PeaHzFam> {

    // 添加家庭成员信息
    default int insertPeaHzFam(List<PeaHzFam> peaHzFamList){
        int rows = 0;
        for (PeaHzFam peaHzFam : peaHzFamList) {
            int insert = this.insert(peaHzFam);
            rows = rows + insert;
        }
        return rows;
    }

    // 根据户主ID查询家庭成员信息
    default List<PeaHzFam> selectFamsByHzId(Long hzId){
        LambdaQueryWrapper <PeaHzFam> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PeaHzFam::getHzId, hzId);
        return this.selectList(queryWrapper);
    }

    // 根据户主ID删除家庭成员
    default int deleteHzFamsByHzId(Long hzId){
        LambdaQueryWrapper<PeaHzFam> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PeaHzFam::getHzId, hzId);
        return this.delete(queryWrapper);
    }
}




